package com
{
	import com.ytplayer.player.YoutubeVideoPlayer;
	import com.ytplayer.remote.RemoteClasses;
	import com.ytplayer.remote.services.LibraryService;
	import com.ytplayer.screen.ScreenController;
	import com.ytplayer.screens.PlayerScreen;
	import com.ytplayer.version.Version;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	/**
	 * Main class of app.
	 * @author Jakub Wagner, FEL
	 */
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			trace("Build " + Version.Major + "." + Version.Minor + "." + Version.Build + " rev." + Version.Revision + " timestamp: " + Version.Timestamp);		

			
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			RemoteClasses.registerClasses();
			
			ScreenController.getInstance().init(stage);
			
			 var yvp:YoutubeVideoPlayer = new YoutubeVideoPlayer();
			 yvp.addEventListener(Event.INIT, onYoutubeVideoPlayerIsReady);
		}
		
		private function onYoutubeVideoPlayerIsReady(e:Event):void 
		{
			ScreenController.getInstance().showScreen(new PlayerScreen());			
		}
		
			
	}
	
}